<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    用户名<input type="text" id='username'><br />
    密码<input type="text" id='password'><br />
    <button id='btn'>登录</button>
</body>
<script src="jquery-1.11.3.js"></script>
<script src="cookie.js"></script>
<script>
$('#btn').click(function(){
    $.ajax({
        type:'get',
        url:'http://localhost/1907/denglu.php',
        data:{key:$("#username").val(),password:$("#password").val()},
        dataType:'json',
        success:function(data){
            if(data['code']==1){
            alert(data.msg)
            location.href="list.html"

            setCookie('user',$("#username").val(),7)    
            
            }else{
                alert(data.msg)
            }           
        }
    })


   

})

</script>

</html>